import { RouteRecordRaw } from 'vue-router';
import { Layout } from '@/router/constant';
import { WalletOutlined } from '@vicons/antd';
import { renderIcon } from '@/utils/index';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 *
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/statistic',
    name: 'Statistic',
    redirect: '/statistic/usage',
    component: Layout,
    meta: {
      title: '统计分析',
      icon: renderIcon(WalletOutlined),
      sort: 9,
      permissions: ['statistic'],
    },
    children: [
      {
        path: 'usage',
        name: 'statistic_usage',
        meta: {
          title: '使用统计',
          permissions: ['usage_list'],
        },
        component: () => import('@/views/statistic/usage/usage.vue'),
      },
      {
        path: 'log',
        name: 'statistic_log',
        meta: {
          title: '日志管理',
          permissions: ['log_list'],
        },
        component: () => import('@/views/statistic/log/log.vue'),
      },
      {
        path: 'audit',
        name: 'statistic_audit',
        meta: {
          title: '审计日志',
          permissions: ['audit_list'],
        },
        component: () => import('@/views/statistic/audit/audit.vue'),
      },
    ],
  },
];

export default routes;
